﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ScheduleMaker.DB.Domain.Core;
using ScheduleMaker.ConfigManager;
using ScheduleMaker.DB.Domain;
using ScheduleMaker.DB;
using ScheduleMaker.DB.CoreDAO;

namespace ScheduleMaker
{
    public partial class smAdmGroupAdd : Form
    {
        smAdminForm parentForm;
        /*
        public smAdmGroupAdd()
        {
            InitializeComponent();
        }
         * */

        public smAdmGroupAdd( smAdminForm _parentForm)
        {
            InitializeComponent();
            this.parentForm = _parentForm;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            // Dodawanie nowej grupy
            GroupDAO groupDAO = DAOFactory.getGroupDAO(ConfigManager.ConfigManager.getConfiguration().Type);

            if ( ConfigManager.ConfigManager.getConfiguration().Type == Mode.School)
            {
                DB.Domain.Core.Group group = new GroupSchool();

                group.Name = tbName.Text;
                groupDAO.save(group);
            }
            else
            {

            }            

            MessageBox.Show("Grupa zsotała dodana", "Dodanie grupy", MessageBoxButtons.OK, MessageBoxIcon.Information);

            this.parentForm.getGroupList();
            this.Dispose();
        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }
    }
}
